package mani.collections;

import java.util.Arrays;


public class StackArray{
	private int size=0;
	private int DEFAULT_CAPACITY = 16;
	private int[] storage;
	
	public StackArray() {
		storage = new int[DEFAULT_CAPACITY];
	}
	
	public void push(int number){
		if(size == storage.length){
			ensureCapa();
		}
		storage[size++] = number;
	}
	
	public int pop(){
		int num = storage[--size];
		storage[size]=(Integer) null;
		return num;
	}

	private void ensureCapa() {
		int newSize = storage.length*2;
		storage = Arrays.copyOf(storage, newSize);		
	}
	

	

}
